package com.uobgroup.ews.uam.core.domain;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.stereotype.Component;

@Component
@Configurable
public class UAMRoleDataOnDemand {

   @PersistenceContext
   EntityManager entityManager;
   
   public void initData(){
      createRole("role 1");
      createRole("role 11");
      createRole("role 2");
      createRole("Role 3");
      createRole("ROLE 4");
   }
   
   private void createRole(String name){
      UAMRole role = new UAMRole();
      role.setName(name);
      entityManager.persist(role);
      entityManager.flush();
   }

}
